<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        let user={id:1,name:'name1'};
        console.log(user);
        let province={id:1,name:'北京'};
        console.log(user.id + '-'+ user.name);
        user.province=province;
        console.log(user);
        let arr=[];
        arr[0] =1;
        console.log(arr.length);
        arr[1]='hello';
        // undefined
        console.log(arr[2]);
        console.log(arr.indexOf('hello'));  //1
        console.log(arr.indexOf('china'));  //-1
        let arr1=new Array();
        arr1[0]=0;
        arr1[1]=1;
        let arr2=new Array(2,3);
        let arr3=[4,5];
        let arr4=arr1.concat(arr2,arr3);
        console.log(arr4);
        // 删除数组最后一个元素,并返回给变量n
        let n=arr4.pop();
        console.log(n);
        console.log(arr4);
        arr4.push(5,6);
        let str=arr4.join(',');
        console.log(str);
        n=arr4.shift(n);//0
        console.log(arr4);// 1 2 3 4 5 6
        //shift和pop相反,shift是第一个元素, pop是最后一个元素
        //和push相反的是unshift,插入第一个元素
        arr4.unshift(0);
        console.log(arr4);
        // 反转
        str=arr4.reverse().join(",");
        console.log(str)
    </script>
</head>
<body>

</body>
</html>